import { _decorator, Component, Label, Node } from 'cc';
import { BasePanel } from './BasePanel';
import { _platform, _player } from '../Main';
import { TT } from '../platforms/minis/TT';
import { Adsdk } from '../scenes/Adsdk';
const { ccclass, property } = _decorator;

@ccclass('EnergyPanel')
export class EnergyPanel extends BasePanel {

    panelName: string = '体力'

    @property(Label)
    energy: Label = null!

    start() {
        super.start()
        this.refreshEnergy()
        Adsdk.instance.showInterstitialAd()
    }

    refreshEnergy() {
        this.energy.string = _player.data.energy + ''
    }
    
    video() {
        _platform.platform.showVideo(() => {
            _player.changeNumData('energy', _player.data, 1, 'add', true, () => {
                this.refreshEnergy()
            })
            let pf = _platform.platform
            if (pf instanceof TT) {
                pf.reportAnalytics('Behavior', {
                    purpose: '获取',
                    type: '道具',
                    name: '体力',
                    amount: 1,
                    source: '广告',
                })
            }
        }, () => {

        })
    }
}


